{% extends 'base.html' %}

{% block content %}

<form action="{% url 'recycleList' %}" method="get">
    <div class="btn-group" role="group">
        <button type="submit" class="btn btn-default" name="env" value="1">生产环境</button>
        <button type="submit" class="btn btn-default" name="env" value="2">测试环境</button>
    </div>
</form>



<div class="wrapper wrapper-content animated fadeIn">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins" id="all">
                <div class="ibox-title">
                    <h5> Web iis详细信息列表</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <form action="{% url 'deployRecycle' %}" method="post" id="checkall">
                        <table class="table table-striped table-bordered table-hover " id="editable" name="editable">
                            <thead>
                                <tr>
                                    <th class="text-center"></th>
                                    <th class="text-center"> 实例名称 </th>
                                    <th class="text-center"> 运行环境 </th>
                                </tr>
                            </thead>
                            <tbody>
                            {% for site in project %}
                                <tr class="gradeX">
                                    <td class="text-center"  data-editable='false'>
                                        <input  name="id" value="{{ site.webSite }},{{ site.env }}" type="radio" class="i-checks" id='services' onchange="getSubmit(this.value)">
                                    </td>
                                    <td class="text-center"> {{ site.webSite }}</td>
                                    <td class="text-center"> {{ site.get_env_display }} </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>

                        <input id='sub' class="btn btn-danger" type="submit" name="action" value="recycle" disabled="disabled">

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    function getSubmit(val) {

        var services = document.getElementsByName("id")
        var count = 0


        for (var i=0;i<services.length;i++) {

            if (services[i].checked) {
                count = count + 1
            }
        }


        if (count != 0){
                $("#sub").attr("disabled", false)
        }
        else {
                $("#sub").attr("disabled", true)
        }
    }
</script>

{% endblock %}

